package cn.taofuxn.sale.controller;

import cn.taofuxn.sale.controller.data.AddConsumerRequest;
import cn.taofuxn.sale.controller.data.ModifyConsumerRequest;
import cn.taofuxn.sale.service.ConsumerService;
import cn.taofuxn.sale.service.data.base.BaseResult;
import io.swagger.annotations.Api;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * ProjectName : GeekSaleSystem
 * PackageName : cn.taofuxn.sale.controller
 * Created by Wong
 * Date: 2018/3/20
 * Time: 15:24
 */
@Api(value = "CustomerController", description = "顾客管理")
@RestController
@RequestMapping(value = "/customer")
public class CustomerController {
	
	@Autowired
	private ConsumerService m_ConsumerService;
	
	@RequestMapping(value = "/getCustomer", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult getCustomer(int page, int pageSize) {
		return m_ConsumerService.getConsumer(page, pageSize);
	}
	
	@RequestMapping(value = "/addCustomer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult addCustomer(@RequestBody AddConsumerRequest vRequest) {
		return m_ConsumerService.addConsumer(vRequest);
	}
	
	@RequestMapping(value = "/modifyCustomer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult modifyCustomer(@RequestBody ModifyConsumerRequest vRequest) {
		return m_ConsumerService.modifyConsumer(vRequest);
	}
	
	@RequestMapping(value = "/deleteCustomer", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public BaseResult deleteCustomer(@Valid @NotBlank @RequestParam String consumerId) {
		return m_ConsumerService.deleteConsumer(consumerId);
	}
	
}
